/**
 * zmn产品模块-产品列表
 * @author tanghongjun
 * @since 2018/10/18
 */
let baseUrl;
layui.define(['index', 'form', 'table', 'laypage', 'zmnApp', 'layedit'], function (exports) {
    var $ = layui.$;
    var form = layui.form;
    var layer = layui.layer;
    var table = layui.table;
    var laypage = layui.laypage;
    var layedit = layui.layedit;
    let zmnApp = layui.zmnApp;
    baseUrl = zmnApp.SYS_BASE_URL;

    table.init('zmn-table', {
        toolbar: "#zmn-table-tool",
        defaultToolbar: [],
        page: true,
        limit: json.pageSize,
        height: 'full-149'
    });
    laypage.render(layui.$.extend({limits:[10, 20, 30, 40, 50,100]},zmnPage.laypageOptions(json)));

    let ids = new Array();

    // 选择（全选或单选）
    table.on("checkbox(zmn-table)", function (obj) {
        ids = table.checkStatus('zmn-table').data.map((item) => item.familyId);
    });

    // 启用/停用
    table.on("toolbar(zmn-table)", function (obj) {
        //启用停用
        if (obj.event != "start" && obj.event != "stop") {
            return false;
        }
        if (ids.length === 0) {
            return layer.alert("请选择至少1条数据！");
        }
        zmnPage.layStartStop(obj, zmnApp.SYS_BASE_URL +"/staff/stafffamily/updateStatus.action", ids.join(","));
    });

    //对外暴露的接口
    exports('plat_stafffamily_list', {});
});

/**
 * 描述: 打开新增/修改家庭关系和联系人页面
 **/
function modifyStaffFamily(staffId, familyId){
    if (familyId == null || familyId == 0) {
        zmnLayUtil.openIframeCustom(layer, baseUrl+"/staff/stafffamily/addEditView.action?staffId="+staffId+"&familyId="+familyId, {title: "新增家庭关系和联系人", shade: 0.8, area:["550px", "510px"]});
    } else {
        zmnLayUtil.openIframeCustom(layer, baseUrl+"/staff/stafffamily/addEditView.action?staffId="+staffId+"&familyId="+familyId, {title: "修改家庭关系和联系人", shade: 0.8, area:["550px", "630px"]});
    }
}

